/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.CompanyInfo;
/*    */ import com.newcrm.bean.Group;
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.DealManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.util.List;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class ShowDealChart extends AbstractAction
/*    */ {
/* 28 */   private static Logger logger = Logger.getLogger(ShowDealChart.class
/* 29 */     .getName());
/*    */ 
/*    */   public ShowDealChart(AbstractHttpServlet servlet)
/*    */   {
/* 32 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 42 */     response.setContentType("text/html;charset=utf-8");
/* 43 */     PrintWriter out = response.getWriter();
/* 44 */     JSONObject jsonObject = new JSONObject();
/*    */ 
/* 46 */     User user = super.getLoginUser(request);
/*    */ 
/* 48 */     if ((!user.isAdmin) && (!user.isGroupAdmin)) {
/* 49 */       jsonObject.put("error", "1");
/* 50 */       out.println(jsonObject);
/* 51 */       out.flush();
/* 52 */       out.close();
/* 53 */       return;
/*    */     }
/*    */ 
/* 56 */     String groupIds = "";
/*    */ 
/* 58 */     if (!user.isAdmin) {
/* 59 */       CompanyInfo company = super.getCompany(request);
/* 60 */       Group group = company.getGroupById(user.groupId);
/* 61 */       if (group != null)
/* 62 */         groupIds = group.getAllIds();
/*    */       else {
/* 64 */         groupIds = String.valueOf(user.groupId);
/*    */       }
/*    */     }
/*    */ 
/* 68 */     DealManager manager = new DealManager();
/*    */ 
/* 70 */     int dealStatus = Util.getURLIntParameter(request
/* 71 */       .getParameter("dealStatus"));
/*    */     try
/*    */     {
/* 74 */       List result = manager.getDealsTotalNumInfo(
/* 75 */         user.companyId, groupIds, dealStatus);
/* 76 */       jsonObject.put("error", "0");
/* 77 */       jsonObject.put("result", result);
/*    */     }
/*    */     catch (DBException e) {
/* 80 */       logger.warn("get deals total num failed", e);
/* 81 */       jsonObject.put("error", "1");
/*    */     }
/* 83 */     out.println(jsonObject);
/* 84 */     out.flush();
/* 85 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ShowDealChart
 * JD-Core Version:    0.6.1
 */